﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ElectronicsMarket.Service.IService;
using ElectronicsMarket.Service.Models;
using System.Drawing;
using System.IO;

namespace ElectronicsMarket.Service.ServiceImpl
{
    public class ConverPictureImpl:IConvertPicture
    {

        MemoryStream stream;
        public byte[] PictureconvertToBinary(Image image)
        {
            byte[] pic_byte= new byte[20];
            stream = new MemoryStream();
            image.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);
            pic_byte = stream.ToArray();
            return pic_byte;
        }
        public System.Drawing.Image BinaryconvertToPicture(byte[] pic_byte)
        {
            stream = new MemoryStream(pic_byte);
            Image img;
            img = Image.FromStream(stream);
            return img;
        }
    }
}